<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="allFile"
          v-hasPermi="['system:role:remove']"
        >1.修改账单账期          一一提示:只更改账单文件命名及sheet表1的封面日期
        </el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="agentMerge"
          v-hasPermi="['system:role:add']"
        >2.物流费用汇总 一一提示:"物流明细"文件夹中对于底稿文件的汇总</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="otherChannel"
          v-hasPermi="['system:role:edit']"
        >3.渠道费用汇总 一一提示:"渠道明细"文件夹中对于底稿文件的汇总</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          :disabled="multiple"
          @click="allToDetail"
          v-hasPermi="['system:role:remove']"
        >4.汇总数据写入对账单 一一提示:将"汇总文件"文件夹中根据客户编码写入对账单 /需注意数据是否全都是数字，不能含有公式，导入账单汇总表需有2账分表（一件代发/渠道），客户编码在最后一列</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="summaryCosts"
          v-hasPermi="['system:role:edit']"
        >5.汇总运费补收</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="freightSurcharge"
          v-hasPermi="['system:role:add']"
        >6.运费补收 一一提示:将"运费补收"文件夹中根据客户编码写入对账单 /客户编码在第一列</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          :disabled="multiple"
          @click="purchaseWaybill"
          v-hasPermi="['system:role:add']"
        >7.购买运单 一一提示:将"购买运单"文件夹中根据客户编码写入对账单 /客户编码在第一列</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          :disabled="multiple"
          @click="workOrder"
          v-hasPermi="['system:role:remove']"
        >8.操作工单和拖柜费 一一提示:将"拖柜费"文件夹中根据客户编码写入对账单/需注意数据是否全都是数字，不能含有公式,且不能有图片</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="unloadCabinet"
          v-hasPermi="['system:role:add']"
        >9.卸柜费 一一提示:将"卸柜费"文件夹中根据客户编码写入对账单/客户编码在S列</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="summaryStorage"
          v-hasPermi="['system:role:edit']"
        >10.汇总仓储明细</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          :disabled="multiple"
          @click="wareHouse"
          v-hasPermi="['system:role:add']"
        >11.仓储费  一一提示:将"仓储费"文件夹中根据客户编码写入对账单 客户编码在倒数第二列</el-button>
      </el-col>
      <br><br><br>
      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="compensation"
          v-hasPermi="['system:role:add']"
        >12.赔付 一一提示:将"赔付"文件夹中根据客户编码写入对账单/客户编码在E列 </el-button>
      </el-col>
      <br><br><br>

      <el-col :span="24">
        <el-button
          type="primary"
          plain
          size="mini"
          :disabled="multiple"
          @click="deletePrevious"
          v-hasPermi="['system:role:remove']"
        >13.删除对账单上期数据</el-button>
      </el-col>
    </el-row>
  </div>

</template>

<script>
import { allFile,agentMerge,otherChannel,allToDetail,freightSurcharge,purchaseWaybill,wareHouse,
  workOrder,unloadCabinet,compensation,summaryStorage,summaryCosts,deletePrevious} from '@/api/amac/fileProcessing'


export default {
  name: "User",
  data() {
    return {
      loading: true,
    };
  },
  methods: {
    // 显示加载动画
    showLoading() {
      return this.$loading({
        lock: true,
        text: '加载中...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      });
    },
    /**
     * 数据1,2处理  修改excel表名并修改指定日期区间
     */
    allFile() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认修改表名并修改指定日期区间').then(function() {
        return allFile();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },
    /**
     * 物流费用底稿预计170份，合并成一张表
     */
    agentMerge() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认物流费用汇总').then(function() {
        return agentMerge();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },
    /**
     * 渠道费用，合并成一张表
     */
    otherChannel() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认物渠道费用汇总').then(function() {
        return otherChannel();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },

    /**
     * 汇总数据写入对账单
     */
    allToDetail() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认汇总数据写入对账单').then(function() {
        return allToDetail();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },
    /**
     * 运费补收
     */
    freightSurcharge() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认运费补收').then(function() {
        return freightSurcharge();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },

    /**
     * 购买运单
     */
    purchaseWaybill() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认购买运单').then(function() {
        return purchaseWaybill();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },

    /**
     * 仓储费
     */
    wareHouse() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认仓储费').then(function() {
        return wareHouse();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },

    /**
     * 操作工单
     */
    workOrder() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认操作工单和拖柜费').then(function() {
        return workOrder();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },

    /**
     * 卸柜费
     */
    unloadCabinet() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认卸柜费').then(function() {
        return unloadCabinet();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },
    /**
     * 赔付
     */
    compensation() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认赔付').then(function() {
        return compensation();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },
    /**
     * 汇总仓储明细
     */
    summaryStorage() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认汇总仓储明细').then(function() {
        return summaryStorage();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },

    /**
     * 汇总运费补收
     */
    summaryCosts() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认汇总运费补收').then(function() {
        return summaryCosts();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },

    /**
     * 删除对账单上期数据
     */
    deletePrevious() {
      this.loadingInstance = this.showLoading();
      this.$modal.confirm('是否确认删除对账单上期数据').then(function() {
        return deletePrevious();
      }).then(() => {
        this.loadingInstance.close();
        this.$modal.msgSuccess("已完成");
      }).catch(() => {
        // 操作失败或取消时，关闭加载动画
        this.loadingInstance.close();
        // 可以选择显示取消或失败的消息
        this.$modal.msgInfo("操作已取消");
      });
    },



  },
};
</script>

<style scoped>
/* 如果有样式需求可以在这里添加 */
</style>
